package com.itheima.duotai.test3;

public class Demo3 {
    public static void main(String[] args) {
        Breeder b = new Breeder("老王",30);
        b.keepPet(new Dog(2,"黑颜色"),"骨头");

        Breeder b1 = new Breeder("老李",25);
        b.keepPet(new Cat(3,"灰颜色")," 鱼");
    }
}
abstract class Animal{
    private int age;
    private String color;

    public Animal() {
    }

    public Animal(int age, String color) {
        this.age = age;
        this.color = color;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
    public abstract void eat(String something);
}

class Dog extends Animal{
    public Dog() {
    }

    public Dog(int age, String color) {
        super(age, color);
    }

    @Override
    public void eat(String something) {
        System.out.println(getAge()+"岁的"+getColor()+"的狗两只前腿死死的抱住"+something+"猛吃");
    }
    public void lookhome(){
        System.out.println("狗狗看家");
    }
}

class Cat extends Animal{
    public Cat() {
    }

    public Cat(int age, String color) {
        super(age, color);
    }

    @Override
    public void eat(String something) {
        System.out.println(getAge()+"岁的"+getColor()+"的猫眯着眼睛侧着头吃"+something);
    }
    public void catchMouse(){
        System.out.println("猫抓老鼠");
    }
}

class Breeder {
    private String name;
    private int age;

    public Breeder() {
    }

    public Breeder(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void keepPet(Animal a,String something){
        System.out.println("年龄为"+getAge()+"岁的"+getName()+"养了一只"+a.getColor()+"的"+a.getAge()+"岁的宠物");
        a.eat(something);
    }
}